<?php include "menu.phtml"; ?>
<div id="right">
	<div class="rightbox">
		<div class="context"><div class="in"><a href="javascript:void(0);" id="context_menu" class="icon_link the_down"><span></span></a></div></div>
		<h1><?php echo $this->translate->_("Edit Subentry"); ?></h1>
		<br />
		<?php echo $this->form; ?>
	</div>
	<div class="rightbox" style="padding: 0px; border: 0px;">
		<?php if(isset($_SERVER['HTTP_REFERER'])): ?>
			<div class="left"><input onclick="Petolio.go('<?php echo $_SERVER['HTTP_REFERER']; ?>');" type="button" value="<?php echo $this->translate->_("< Back to List"); ?>" id="submit" name="prev" style="margin: 0px;"><div class="clear"></div></div>
			<div class="clear"></div>
		<?php else: ?>
			<div class="left"><input onclick="Petolio.go('<?php echo $this->url(array('controller'=>'shot', 'action'=>'view', 'id'=> $this->record->getId()), 'default', true) ?>');" type="button" value="<?php echo $this->translate->_("< Back to List"); ?>" id="submit" name="prev" style="margin: 0px;"><div class="clear"></div></div>
			<div class="clear"></div>
		<?php endif; ?>
	</div>
</div>
<script type="text/javascript">
	var Transform = function() {
		var store = {

		}, bind = function() {
			var sel_1 = $('input[name="immunization"]').val() == 'Initial immunization' ? 'selected="selected"' : '',
				sel_2 = $('input[name="immunization"]').val() == 'Revaccination' ? 'selected="selected"' : '';

			$('input[name="immunization"]').replaceWith(
				'<select class="chzn-select" name="immunization" id="immunization" rel="#immunization-select">'+
					'<option value="Initial immunization" '+ sel_1 +'><?php echo Petolio_Service_Util::Tr('Initial immunization'); ?></option>'+
					'<option value="Revaccination" '+ sel_2 +'><?php echo Petolio_Service_Util::Tr('Revaccination'); ?></option>'+
				'</select>'
			);

			Petolio.handleSelects();

		}, __construct = function() {
			bind();
		};

		return {
			init: __construct
		};
	}();

	READY(Transform.init);

	var ShotRecordSubentry = function() {
		function __construct() {
			$("#save_sr").val('<?php echo $this->translate->_('Save Subentry'); ?>'); // nice bug
			$("#save_sr").click(function(e) {
				e.preventDefault();
				$("#add_shot_record_subentry").submit();
			});
		};

		return {
			init: __construct,
		};
	}();

	READY(ShotRecordSubentry.init);
</script>